package router

import (
	"encoding/json"
	log "github.com/sirupsen/logrus"
	"queue-gateway/amqp"
	"queue-gateway/databases"
	"time"
)

type baseHandler interface {
	genCallbackHttpResponse()
}

//type Response struct {
//}

func genCallbackHttpResponse(msgID string) *amqp.TaskResult {
	var taskResult amqp.TaskResult
	for {
		resultTemp := databases.GetVal(msgID)
		if resultTemp != "" {
			resultbytes := []byte(resultTemp)
			json.Unmarshal(resultbytes, &taskResult)
			log.Debugln("genCallbackHttpResponse:", taskResult)
			return &taskResult
		}
		time.Sleep(time.Millisecond * 10)
	}
}
